/**
 * @name 封装Taro.request
 *
 */
import Taro from "@tarojs/taro";
export const fetch = (url, method, data) => {
  return new Promise((resolve, reject) => {
    Taro.request({
      url,
      method,
      data,
      success: (res) => {
        console.log("rse:", res);
        if (res.statusCode === 500) {
          reject(res.data);
        } else {
          resolve(res);
        }
      },
      fail: (error) => {
        reject(error);
      },
    });
  });
};
